USE [CDMS_UAT]
GO

/****** Object:  Table [dbo].[Claim]    Script Date: 04/02/2015 18:14:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Claim](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[EntryOwner] [nvarchar](128) NOT NULL,
	[EntryDateTime] [datetime] NOT NULL,
	[ClaimDate] [datetime] NOT NULL,
	[StartWorkTime] [datetime] NOT NULL,
	[EndWorkTime] [datetime] NOT NULL,
	[StartOverTime] [datetime] NULL,
	[EndOverTime] [datetime] NULL,
	[OT1_5] [decimal](5, 4) NULL,
	[OT2_0] [decimal](5, 4) NULL,
	[PH] [bit] NULL,
	[RD4] [bit] NULL,
	[RD8] [bit] NULL,
	[AlwShft] [decimal](5, 2) NULL,
	[AlwMeal] [decimal](5, 2) NULL,
	[ShiftType] [nvarchar](10) NULL,
	[Remark] [nvarchar](max) NULL,
	[Status] [tinyint] NULL,
	[Exported] [char](1) NULL,
	[_Action] [char](1) NULL,
	[SubmissionDate] [datetime] NULL,
	[CheckerId] [nvarchar](128) NULL,
	[RejectionDate] [datetime] NULL,
	[RejectReason] [nvarchar](max) NULL,
	[RejectorId] [nvarchar](128) NULL,
	[ApprovedDate] [datetime] NULL,
	[ApproverId] [nvarchar](128) NULL,
 CONSTRAINT [PK__Claim__3214EC07056ECC6A] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


USE [CDMS_UAT]
/****** Object:  Index [IX_Claim_1]    Script Date: 04/02/2015 18:14:38 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_Claim_1] ON [dbo].[Claim] 
(
	[EntryOwner] ASC,
	[ClaimDate] ASC,
	[StartWorkTime] ASC,
	[EndWorkTime] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

/****** Object:  Trigger [dbo].[Claim_INS_TRG]    Script Date: 04/02/2015 18:14:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[Claim_INS_TRG] ON [dbo].[Claim]
FOR INSERT
AS 	
(
    SELECT COUNT(*) FROM inserted
);

GO

ALTER TABLE [dbo].[Claim] ADD  CONSTRAINT [DF_Claim_EntryDateTime]  DEFAULT (getdate()) FOR [EntryDateTime]
GO

ALTER TABLE [dbo].[Claim] ADD  CONSTRAINT [DF_Claim_Status]  DEFAULT ((0)) FOR [Status]
GO

